<html>
<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<head>
<title>Section 8.8.&nbsp; wait3 and wait4 Functions</title>
<link rel="STYLESHEET" type="text/css" href="images/style.css">
<link rel="STYLESHEET" type="text/css" href="images/docsafari.css">
</head>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><td><div STYLE="MARGIN-LEFT: 0.15in;"><a href="toc.html"><img src="images/team.gif" width="60" height="17" border="0" align="absmiddle"  alt="Team BBL"></a></div></td>
<td align="right"><div STYLE="MARGIN-LEFT: 0.15in;">
<a href=ch08lev1sec7.html><img src="images/prev.gif" width="60" height="17" border="0" align="absmiddle" alt="Previous Page"></a>
<a href=ch08lev1sec9.html><img src="images/next.gif" width="60" height="17" border="0" align="absmiddle" alt="Next Page"></a>
</div></td></tr></table>
<br><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td valign="top"><a name="ch08lev1sec8"></a>
<h3 class="docSection1Title">8.8. <tt>wait3</tt> and <tt>wait4</tt> Functions</h3>
<p class="docText"><a name="idd1e56042"></a><a name="idd1e56047"></a><a name="idd1e56050"></a><a name="idd1e56055"></a><a name="idd1e56058"></a><a name="idd1e56061"></a><a name="idd1e56064"></a><a name="idd1e56067"></a><a name="idd1e56072"></a><a name="idd1e56079"></a><a name="idd1e56084"></a>Most UNIX system implementations provide two additional functions: <tt>wait3</tt> and <tt>wait4</tt>. Historically, these two variants descend from the BSD branch of the UNIX System. The only feature provided by these two functions that isn't provided by the <tt>wait</tt>, <tt>waitid</tt>, and <tt>waitpid</tt> functions is an additional argument that allows the kernel to return a summary of the resources used by the terminated process and all its child processes.</P>
<a name="inta378"></a><P><table cellspacing="0" class="allBorders" border="1" RULES="none" cellpadding="5"><colgroup><col width="550"></colgroup><thead></thead><tr><TD class="docTableCell" align="left" valign="top"><p class="docText">
<a name="PLID0"></a><div class="v1"><a href="ch08lev1sec8.html#PLID0">[View full width]</a></div><pre>
#include &lt;sys/types.h&gt;
#include &lt;sys/wait.h&gt;
#include &lt;sys/time.h&gt;
#include &lt;sys/resource.h&gt;

pid_t wait3(int *<span class="docEmphItalicAlt">statloc</span>, int <span class="docEmphItalicAlt">options</span>, struct
<img border="0" width="14" height="9" alt="" align="left" src="images/ccc.gif"> rusage *<span class="docEmphItalicAlt">rusage</span>);

pid_t wait4(pid_t <span class="docEmphItalicAlt">pid</span>, int *<span class="docEmphItalicAlt">statloc</span>, int <span class="docEmphItalicAlt">options</span>,
<img border="0" width="14" height="9" alt="" align="left" src="images/ccc.gif"> struct rusage *<span class="docEmphItalicAlt">rusage</span>);
</pre><BR>
</P></td></TR><TR><TD class="docTableCell" align="right" valign="top"><p class="docText">Both return: process ID if OK, 0, or 1 on error</p></TD></tr></table></P><BR>
<p class="docText">The resource information includes such statistics as the amount of user CPU time, the amount of system CPU time, number of page faults, number of signals received, and the like. Refer to the <tt>geTRusage</tt>(2) manual page for additional details. (This resource information differs from the resource limits we described in <a class="docLink" href="ch07lev1sec11.html#ch07lev1sec11">Section 7.11</a>.) <a class="docLink" href="#ch08fig11">Figure 8.11</a> details the various arguments supported by the <tt>wait</tt> functions.</p>
<a name="ch08fig11"></a><P><table cellspacing="0" class="allBorders" border="1" RULES="groups" cellpadding="5"><caption><H5 class="docTableTitle">Figure 8.11. Arguments supported by <tt>wait</tt> functions on various systems</h5></caption><colgroup><col width="56"><col width="55"><col width="55"><col width="55"><col width="55"><col width="56"><col width="56"><col width="56"><col width="56"></colgroup><thead><TR><th class="rightBorder bottomBorder thead" scope="col" align="center" valign="middle"><p class="docText"><span class="docEmphRoman">Function</span></P></th><th class="rightBorder bottomBorder thead" scope="col" align="center" valign="middle"><p class="docText"><span class="docEmphRoman"><span class="docEmphasis">pid</span></span></p></th><th class="rightBorder bottomBorder thead" scope="col" align="center" valign="middle"><p class="docText"><span class="docEmphRoman"><span class="docEmphasis">options</span></span></p></th><th class="rightBorder bottomBorder thead" scope="col" align="center" valign="middle"><p class="docText"><span class="docEmphRoman"><span class="docEmphasis">rusage</span></span></p></th><th class="rightBorder bottomBorder thead" scope="col" align="center" valign="middle"><p class="docText"><span class="docEmphRoman">POSIX.1</span></p></th><th class="bottomBorder thead" scope="col" align="center" valign="bottom"><p class="docText"><span class="docEmphRoman">Free BSD 5.2.1</span></P></th><th class="bottomBorder thead" scope="col" align="center" valign="bottom"><p class="docText"><span class="docEmphRoman">Linux 2.4.22</span></p></th><th class="bottomBorder thead" scope="col" align="center" valign="bottom"><p class="docText"><span class="docEmphRoman">Mac OSX 10.3</span></P></th><th class="bottomBorder thead" scope="col" align="center" valign="bottom"><p class="docText"><span class="docEmphRoman">Solaris 9</span></p></th></TR></thead><tr><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>wait</tt></p></td><td class="rightBorder" align="left" valign="top">&nbsp;</td><td class="rightBorder" align="left" valign="top">&nbsp;</td><td class="rightBorder" align="left" valign="top">&nbsp;</td><td class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD></TR><TR><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>waitid</tt></P></td><TD class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</P></TD><td class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</P></TD><td class="rightBorder" align="left" valign="top">&nbsp;</TD><TD class="rightBorder" align="center" valign="top"><p class="docText">XSI</p></td><td class="docTableCell" align="left" valign="top">&nbsp;</td><TD class="docTableCell" align="left" valign="top">&nbsp;</td><TD class="docTableCell" align="left" valign="top">&nbsp;</td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td></tr><tr><td class="rightBorder bottomBorder" align="left" valign="top"><p class="docText"><tt>waitpid</tt></p></td><td class="rightBorder bottomBorder" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="rightBorder bottomBorder" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="rightBorder bottomBorder" align="left" valign="top">&nbsp;</td><td class="rightBorder bottomBorder" align="center" valign="top"><p class="docText">&#8226;</p></TD><TD class="bottomBorder" align="center" valign="top"><p class="docText">&#8226;</p></TD><TD class="bottomBorder" align="center" valign="top"><p class="docText">&#8226;</P></td><TD class="bottomBorder" align="center" valign="top"><p class="docText">&#8226;</P></TD><td class="bottomBorder" align="center" valign="top"><p class="docText">&#8226;</P></td></TR><TR><TD class="rightBorder" align="left" valign="top"><p class="docText"><tt>wait3</tt></p></TD><TD class="rightBorder" align="left" valign="top">&nbsp;</td><TD class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</P></td><td class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</p></td><TD class="rightBorder" align="left" valign="top">&nbsp;</td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td></tr><tr><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>wait4</tt></p></td><td class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</p></td><TD class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</P></td><TD class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</P></TD><td class="rightBorder" align="left" valign="top">&nbsp;</TD><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></td></TR></table></P><br>
<blockquote>
<p class="docText">The <tt>wait3</tt> function was included in earlier versions of the Single UNIX Specification. In Version 2, <tt>wait3</tt> was moved to the legacy category; <tt>wait3</tt> was removed from the specification in Version 3.</p>
</blockquote>

<a href="17021535.html"><img src="images/pixel.gif" alt="" width="1" height="1" border="0"></a><ul></ul></TD></tr></table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><td><div STYLE="MARGIN-LEFT: 0.15in;"><a href="toc.html"><img src="images/team.gif" width="60" height="17" border="0" align="absmiddle"  alt="Team BBL"></a></div></td>
<td align="right"><div STYLE="MARGIN-LEFT: 0.15in;">
<a href=ch08lev1sec7.html><img src="images/prev.gif" width="60" height="17" border="0" align="absmiddle" alt="Previous Page"></a>
<a href=ch08lev1sec9.html><img src="images/next.gif" width="60" height="17" border="0" align="absmiddle" alt="Next Page"></a>
</div></td></tr></table>
</body></html><br>
<table width="100%" cellspacing="0" cellpadding="0"
style="margin-top: 0pt; border-collapse: collapse;"> 
<tr> <td align="right" style="background-color=white; border-top: 1px solid gray;"> 
<a href="http://www.zipghost.com/" target="_blank" style="font-family: Tahoma, Verdana;
 font-size: 11px; text-decoration: none;">The CHM file was converted to HTM by Trial version of <b>ChmD<!--159-->ecompiler</b>.</a>
</TD>
</TR><tr>
<td align="right" style="background-color=white; "> 
<a href="http://www.etextwizard.com/download/cd/cdsetup.exe" target="_blank" style="font-family: Tahoma, Verdana;
 font-size: 11px; text-decoration: none;">Download <b>ChmDec<!--159-->ompiler</b> at: http://www.zipghost.com</a>
</TD></tr></table>
